package com.sdhs.archivesmanage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.archivesmanage.domain.GcFileManagement;
import com.sdhs.archivesmanage.service.IGcFileManagementService;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.common.core.page.TableDataInfo;

/**
 * 档案管理Controller
 *
 * @author andong
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/archivesmanage/management")
public class GcFileManagementController extends BaseController
{
    @Autowired
    private IGcFileManagementService gcFileManagementService;

    /**
     * 查询档案管理列表
     */
    @PreAuthorize("@ss.hasPermi('archivesmanage:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcFileManagement gcFileManagement)
    {
        startPage();
        List<GcFileManagement> list = gcFileManagementService.selectGcFileManagementList(gcFileManagement);
        return getDataTable(list);
    }

    /**
     * 导出档案管理列表
     */
    @PreAuthorize("@ss.hasPermi('archivesmanage:management:export')")
    @Log(title = "档案管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcFileManagement gcFileManagement)
    {
        List<GcFileManagement> list = gcFileManagementService.selectGcFileManagementList(gcFileManagement);
        ExcelUtil<GcFileManagement> util = new ExcelUtil<GcFileManagement>(GcFileManagement.class);
        util.exportExcel(response, list, "档案管理数据");
    }

    /**
     * 获取档案管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('archivesmanage:management:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcFileManagementService.selectGcFileManagementById(id));
    }

    /**
     * 新增档案管理
     */
    @PreAuthorize("@ss.hasPermi('archivesmanage:management:add')")
    @Log(title = "档案管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcFileManagement gcFileManagement)
    {
        return toAjax(gcFileManagementService.insertGcFileManagement(gcFileManagement));
    }

    /**
     * 修改档案管理
     */
    @PreAuthorize("@ss.hasPermi('archivesmanage:management:edit')")
    @Log(title = "档案管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcFileManagement gcFileManagement)
    {
        return toAjax(gcFileManagementService.updateGcFileManagement(gcFileManagement));
    }

    /**
     * 删除档案管理
     */
    @PreAuthorize("@ss.hasPermi('archivesmanage:management:remove')")
    @Log(title = "档案管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcFileManagementService.deleteGcFileManagementByIds(ids));
    }
}
